//
//  SPPromptView.m
//  penzer
//
//  Created by 还带大道 on 2018/11/6.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "SPPromptView.h"

@implementation SPPromptView


- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        [self initUI];
    }
    return self;
}


- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if(self = [super initWithCoder:aDecoder]){
        [self initUI];
    }
    return self;
}


- (void)initUI
{
    self.backgroundColor = RZ_COLOR(254, 252, 236);
    UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_gonggao"]];
    [self addSubview:imageV];
    [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.equalTo(self);
    }];
    
    UILabel *title = [UILabel new];
    _titleL = title;
    title.textColor = [UIColor orangeColor];
    title.font = [UIFont systemFontOfSize:14];
    title.text = @"当前位置有10张优惠券可用";
    [self addSubview:title];
    [title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageV.mas_right).offset(10);
        make.centerY.equalTo(self);
    }];
    
    
    UIButton *btn = [UIButton new];
    [btn setImage:[UIImage imageNamed:@"icon_gggb"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [self addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.right.equalTo(self);
        make.width.mas_equalTo(44);
    }];
}



- (void)close
{
    !self.closeBlock?:self.closeBlock();
}


- (void)layoutSubviews
{
    [super layoutSubviews];
   
}

@end
